#ifndef _ARRAY_BINARY_TREE_H
#define _ARRAY_BINARY_TREE_H

#include "Typedef.h"

#define BINARY_TREE_SIZE 50
#define NOT_EMPTY_INDEX -1

/********************************************************** 
              STRUCTURES
***********************************************************/
/*! @brief Node structure for Array Binary Tree */
typedef struct A_Node
{
  int   _element;
  A_Node *_left_node_ptr;
  A_Node *_right_node_ptr;
  /* index to next node, let's use -1 for the node that is not empty */
  int _next;
} A_Node;

/*! @brief Array Binary Tree structure */
typedef struct Array_Binary_Tree
{
  A_Node                    *_root_ptr;
  uint                       _head_index;
  uint                       _tail_index;
  uint                       _size;
  A_Node                     _nodes[BINARY_TREE_SIZE];
} Array_Binary_Tree;

/********************************************************** 
              FUNCTIONS
***********************************************************/
/*! @brief Function to initialize the binary tree */
void a_init_binary_tree(void);

/*! @brief Function that returns the size of the tree */
uint a_size(void);

/*! @brief Inserts an element into the tree 
    @return true if inserted, false otherwise
 */
bool a_insert_element
(
  int element
);

/*! @brief Deletes an element from the tree 
    @return true if deleted from the tree,
            false otherwise
  */
bool a_delete_element
(
  int element
);

/*! @brief Finds an element from the tree 
    @return NULL if not found.
  */
A_Node* a_find_element
(
  int element
);


#endif
